import { Sequelize, DataTypes } from 'sequelize'
import moment from 'moment'
import sequelize from './sequelize'

// 健康信息
const JiankangxinxiModel = sequelize.define('JiankangxinxiModel', {
	id: {
		type: DataTypes.BIGINT,
		primaryKey: true,
		autoIncrement: true,
		allowNull: false,
		comment: '主键id'
	},
	mingcheng: {
		type: DataTypes.STRING,
		defaultValue: '',
		allowNull: true,
		comment: '名称'
	},
	tupian: {
		type: DataTypes.TEXT,
		defaultValue: '',
		allowNull: true,
		comment: '图片'
	},
	jinritiwen: {
		type: DataTypes.FLOAT,
		defaultValue: 0,
		allowNull: true,
		comment: '今日体温'
	},
	shifoubushi: {
		type: DataTypes.STRING,
		defaultValue: '',
		allowNull: true,
		comment: '是否不适'
	},
	youwuyichang: {
		type: DataTypes.TEXT,
		defaultValue: '',
		allowNull: true,
		comment: '有无异常'
	},
	xuehao: {
		type: DataTypes.STRING,
		defaultValue: '',
		allowNull: true,
		comment: '学号'
	},
	xingming: {
		type: DataTypes.STRING,
		defaultValue: '',
		allowNull: true,
		comment: '姓名'
	},
	shangchuanriqi: {
		type: DataTypes.DATEONLY,
		allowNull: true,
		get() {
            return moment(this.getDataValue('shangchuanriqi')).format('YYYY-MM-DD')
        },
		comment: '上传日期'
	},
	addtime: {
  		type: DataTypes.DATE,
  		defaultValue: DataTypes.NOW,
    	allowNull: false,
    	get() {
            return moment(this.getDataValue('addtime')).format('YYYY-MM-DD HH:mm:ss')
        },
		comment: '添加时间'
	}
}, {
	timestamps: false,
	freezeTableName: true,
	tableName: 'jiankangxinxi'
})

export default JiankangxinxiModel
